package com._520it.smis.web.servlert;

import java.io.IOException;
import java.util.List;

import javax.servlet.ServletException;
import javax.servlet.annotation.WebServlet;
import javax.servlet.http.HttpServlet;
import javax.servlet.http.HttpServletRequest;
import javax.servlet.http.HttpServletResponse;

import com._520it.smis.dao.IStudentDao;
import com._520it.smis.dao.impl.StudentDaoImpl;
import com._520it.smis.domain.Student;

@WebServlet("/student/list")
public class ListStudentServlet extends HttpServlet {

	private static final long serialVersionUID = 1L;
	
	private IStudentDao dao;
	
	@Override
	public void init() throws ServletException {
		dao = new StudentDaoImpl();
	}
	
	@Override
	protected void service(HttpServletRequest req, HttpServletResponse resp) throws ServletException, IOException {
		
		List<Student>list = dao.list();
		req.setAttribute("students", list);
		req.getRequestDispatcher("/WEB-INF/views/student/list.jsp").forward(req,resp);
	}

}
